﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Core.Core;

namespace www.pages.tag
{
    public partial class tag : System.Web.UI.Page
    {
        public string IsshowDocHtml = " style=\"display: none\"";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) {
                hid_project.Value = Request["project"]??"0";
                hid_tagid.Value = Request["tag"] ?? "0";
                BindData();
                BindTag();
            }
        }

        private void BindData() {
            list_docs.DataSource = DocumentUtil.GetList(Convert.ToInt32(hid_project.Value));
            list_docs.DataBind();
        }

        private void BindTag() {
            var tag = TagUtil.Get(Convert.ToInt32(hid_project.Value), Convert.ToInt32(hid_tagid.Value));
            this.txt_tagname.Value = tag?.tag_name;
            this.sl_type.SelectedValue = tag?.tag_type;
            this.txt_tagcomment.Value = tag?.tag_comment;
            this.txtText.Value = tag?.tag_content;
            if (tag?.tag_type == "exclusive") {
                IsshowDocHtml = " style=\"display: block\"";
            }
        }
        #region 页面代码
        /// <summary>
        /// 
        /// </summary>
        /// <param name="doc_id"></param>
        /// <param name="tag_id"></param>
        /// <returns></returns>
        public string createCheckHtml(string doc_id, string tag_id)
        {
            string Ischecked = "";
            if (tag_id != "0") { Ischecked = "checked"; }
            return $"<input type=\"checkbox\" data-docid=\"{doc_id}\" {Ischecked}/>";
        } 
        #endregion
    }
}